<template>
  <div class="wrap">
    <div class="header">
      <div class="left">
        <img :src="info.avatar" :onerror="defaultImg" class="headerUrl" alt />
        <div class="center">
          <div>
            <p>{{info.username}}</p>
            <span>订单数：{{info.total}}</span>
          </div>
          <p>{{info.signature}}</p>
        </div>
      </div>
      <div class="func">
        <p @click="followdele">取消关注</p>
        <!-- <p>查看商圈</p> -->
      </div>
    </div>
    <div class="centers" v-if="w_list">
      <div class="b-tit" @click="showInfos">
        <p>暂无物流信息</p>
        <p class="bchos">查看</p>
      </div>
      <div class="item" v-for="(item,idx) in w_list.orderList" :key="idx">
        <div class="item-left">
          <img
            :src="item.order_image"
            @click="showMaxImg(item.order_image)"
            :onerror="defaultImg2"
            class="avi"
            alt
          />
          <div class="productInfo">
            <p>规格：{{item.order_size}}</p>
            <p>价格：￥{{item.supplier_price}}</p>
            <p>
              商家备注：
              <span style="color:#FF536B;">{{item.remark?item.remark:'无备注'}}</span>
            </p>
          </div>
        </div>
      </div>
    </div>
    <div class="centers" v-if="y_list">
      <div class="b-tit" @click="showInfo">
        <p>中通快递：{{y_list.waybill}}</p>
        <p class="bchos">查看</p>
      </div>
      <div class="item" v-for="(item,idx) in y_list.orderList" :key="idx">
        <div class="item-left">
          <img :src="item.order_image"  @click="showMaxImg(item.order_image)" :onerror="defaultImg2" class="avi" alt />
          <div class="productInfo">
            <p>规格：{{item.order_size}}</p>
            <p>价格：￥{{item.supplier_price}}</p>
            <p>
              商家备注：
              <span style="color:#FF536B;">明天</span>
            </p>
          </div>
        </div>
      </div>
    </div>
     <van-popup v-model="maxImgShow">
      <img :src="maxImg" class="maxImg" :onerror="defaultImg2" alt />
    </van-popup>
  </div>
</template>
<style lang="scss" scoped>
.maxImg{
  width: 100%;
}
.wrap {
  background: #f7f7f7;
  width: 100%;
  height: 100vh;
}
.header {
  height: 2.186667rem;
  padding: 0 0.4rem 0.4rem;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .left {
    display: flex;
    align-items: center;
  }
  .headerUrl {
    width: 1.466667rem;
    height: 1.466667rem;
    border-radius: 50%;
    display: block;
    margin-top: 0.373333rem;
    object-fit: cover;
  }
  .center {
    margin-left: 0.4rem;
    div {
      margin-top: 15px;
      p {
        color: #555;
        font-size: 0.48rem;
      }
      span {
        color: #999;
        font-size: 0.293333rem;
        display: block;
        text-align: left;
        margin: 5px 0;
      }
    }
    p {
      color: #555;
      font-size: 0.266667rem;
      text-align: left;
    }
  }
  .func {
    margin-top: 15px;
    p:nth-of-type(1) {
      width: 2.24rem;
      height: 0.6rem;
      border: 2px solid rgba(63, 217, 201, 1);
      color: #3fd9c9;
      border-radius: 0.4rem;
      font-size: 0.373333rem;
      text-align: center;
      line-height: 0.6rem;
      margin-bottom: 0.266667rem;
    }
    p:nth-of-type(2) {
      width: 2.24rem;
      height: 0.6rem;
      background: rgba(63, 217, 201, 1);
      color: #fff;
      border-radius: 0.4rem;
      font-size: 0.373333rem;
      text-align: center;
      line-height: 0.6rem;
    }
  }
}

.centers {
  width: 9.466667rem;
  background: #fff;
  overflow-y: scroll;
  margin: 0.186667rem auto 0.4rem;
  border-radius: 0.266667rem;
  .b-tit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.2rem;
    margin-bottom: 0.4rem;
    p {
      color: #555;
      font-size: 0.346667rem;
      font-weight: bold;
      margin-left: 0.133333rem;
    }
    .bchos {
      color: #fff;
      font-size: 0.32rem;
      text-align: center;
      background: #3fd9c9;
      border-radius: 50px;
      padding: 2px 20px;
      margin-right: 8px;
      font-weight: normal;
    }
  }
  .item {
    width: 9.466667rem;
    padding-bottom: 10px;

    overflow: hidden;
    display: flex;
    justify-content: space-between;
    .item-left {
      display: flex;
      align-items: center;
    }
    .avi {
      width: 2rem;
      height: 2rem;
      border-radius: 0.266667rem;
      margin: 0 0.306667rem 0 0.133333rem;
      display: block;
      object-fit: cover;
    }
    .productInfo {
      height: 1.8rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      p {
        color: #555;
        font-size: 0.32rem;
        text-align: left;
      }
      p:nth-of-type(2) {
        margin-top: 0.133333rem;
        margin-bottom: 0.186667rem;
      }
    }
    .item-right {
      display: flex;
      .state {
        width: 2.4rem;

        p:nth-of-type(1) {
          color: #ff536b;
          font-size: 0.426667rem;
          text-align: center;
          margin-top: 0.266667rem;
          margin-bottom: 0.56rem;
        }
        p:nth-of-type(2) {
          width: 2.213333rem;
          height: 0.573333rem;
          border-radius: 0.266667rem;
          text-align: center;
          background: #3fd9c9;
          font-size: 0.373333rem;
          line-height: 0.573333rem;
          color: #fff;
        }
      }
      .radio {
        width: 0.453333rem;
        height: 0.453333rem;
        border-radius: 50%;
        display: block;
        background: #3fd9c9;
        margin-right: 0.266667rem;
        margin-top: 0.3rem;
      }
    }
  }
}
</style>
<script>
import { getProxyOrderList, followDele } from "@/utils/interface";
import { Toast, Dialog } from "vant";

export default {
  data() {
    return {
      info: {},
      w_list: null,
      y_list: null,
      defaultImg: 'this.src="' + require("../assets/user2.png") + '"',
      defaultImg2: 'this.src="' + require("../assets/timg.jpg") + '"',
      maxImgShow:false,
      maxImg:""
    };
  },
  created() {
    document.title = "发货订单";
    this.info = JSON.parse(this.$route.query.info);
    this.getList(this.info.user_id);
  },
  methods: {
    next() {
      this.$router.push("/submitOrder");
    },
    showInfo() {
      this.$router.push({
        name: "mySendOrderDetail",
        query: {
          state: 2,
          info: JSON.stringify(this.info),
          y_list: JSON.stringify(this.y_list)
        }
      });
    },
    // 查看暂无物流信息
    showInfos() {
      this.$router.push({
        name: "mySendOrderDetail",
        query: {
          state: 1,
          info: JSON.stringify(this.info),
          w_list: JSON.stringify(this.w_list)
        }
      });
    },
    getList(id) {
      getProxyOrderList({ parentId: id }).then(res => {
        console.log(res.data);
        for (var i = 0; i < res.data.data.length; i++) {
          if (res.data.data[i].is_sent == 0) {
            this.w_list = res.data.data[i];
          } else {
            this.y_list = res.data.data[i];
          }
        }
      });
    },
    // 取消关注
    followdele() {
      Dialog.confirm({
        title: "提示",
        message: "是否取消关注该商家"
      })
        .then(() => {
          followDele({ bizUserId: this.info.user_id }).then(res => {
            if (res.data.code == 200) {
              Toast.success("取消成功");
              this.$router.go(-1);
            }
          });
        })
        .catch(() => {
          // on cancel
        });
    },
    showMaxImg(s) {
      this.maxImgShow = true;
      this.maxImg = s;
    }
  }
};
</script>